/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jojo.home.wallet.web;

import java.awt.event.ActionEvent;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import jojo.home.wallet.entity.um.FwUser;
import jojo.home.wallet.local.um.FwUserLocal;

/**
 *
 * @author Ganduruu
 */
@ManagedBean (name = "fwUserMBean")
@SessionScoped
public class FwUserMBean {
    
    @EJB
    private FwUserLocal userBean;
    
    private String username;
    private String password;
    
    private FwUser user = new FwUser();

    public void test () {
        System.out.println("user first : " + user.getUsername());
        user = userBean.getUser(1L);      
        System.out.println("user later : " + user.getUsername());
    }
    
    public String login() {
        if (user == null) {
            user = new FwUser();
        }
        
        user = userBean.login(username, password);
        System.out.println("user : " + user.getUsername());
        
        return "userList";
    }
        
    public FwUser getUser() {
        return user;
    }

    public void setUser(FwUser user) {
        this.user = user;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
